rss
Library for deserializing and serializing the RSS web content syndication format.
Supported Versions
Reading from the following RSS versions is supported:
- RSS 0.90
- RSS 0.91
- RSS 0.92
- RSS 1.0
- RSS 2.0
Writing support is limited to RSS 2.0.
Documentation
Usage
Add the dependency to your Cargo.toml
.
[]
= "2.0"
Reading
A channel can be read from any object that implements the BufRead
trait.
From a file
use File;
use BufReader;
use Channel;
let file = open.unwrap;
let channel = read_from.unwrap;
From a buffer
Note: This example requires reqwest crate.
use Error;
use Channel;
async
Writing
A channel can be written to any object that implements the Write
trait or converted to an XML string using the ToString
trait.
use Channel;
let channel = default;
channel.write_to.unwrap; // // write to the channel to a writer
let string = channel.to_string; // convert the channel to a string
Creation
Builder methods are provided to assist in the creation of channels.
Note: This requires the builders
feature, which is enabled by default.
use ChannelBuilder;
let channel = default
.title
.link
.description
.build
.unwrap;
Validation
Validation methods are provided to validate the contents of a channel against the RSS specification.
Note: This requires enabling the validation
feature.
use Channel;
use Validate;
let channel = default;
channel.validate.unwrap;
Extensions
Elements which have non-default namespaces will be considered extensions. Extensions are stored in Channel.extensions
and Item.extensions
.
For convenience, Dublin Core, Syndication and iTunes extensions are extracted to structs and stored in as properties on channels and items.
Invalid Feeds
As a best effort to parse invalid feeds rss
will default elements declared as "required" by the RSS 2.0 specification to an empty string.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.